<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${tabTitle}</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <form id="prj_no_sign_time_edit_info">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_100" id="searchPrjStsCdId">
                        <div class="label">机构名称</div>
                        <div class="field">
                            ${insName}
<%--                            <input id="insName" name="insName" value="" disabled="disabled">--%>
                        </div>
                    </div>
                    <div class="fieldBox col_66_auto" >
                        <div class="label">不可签署时间</div>
                        <div class="field">
                            <input name="startTime" id="startTime" type="text" class="ui-datepicker" value="" validate="{required:true}">-
                            <input name="endTime" id="endTime" type="text" class="ui-datepicker" value="" validate="{required:true}">
                        </div>
                    </div>
                <input id="id" value="${id}" type="hidden">

                </div>
                <div class="btnsBox" style="text-align: center;">
                    <span id="saveBtn"  class="sq-button sq-button-round">保存</span>
                    <span id="cancelBtn" class="sq-button sq-button-round">取消</span>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function(){

        $("#startTime").ligerDateEditor({
            showTime: true,
            width:"180",
            format:"hh:mm"
        });
        $("#endTime").ligerDateEditor({
            showTime: true,
            width:"180",
            format:"hh:mm"
        });

        var prj_no_sign_time_edit_info = $('#prj_no_sign_time_edit_info').ligerForm({
            validate : true
        });
        SET_popupIframeHeight();

    })
    //关闭
    $('#cancelBtn').click(function(){
        frameElement.dialog.close();
    });
    //保存
    $('#saveBtn').click(function(){
        var options = $("#insId option:selected");　　　　//获取选中项
        var insId = options.val();
        var startTm = $("#startTime").val();
        var endTm = $("#endTime").val()
        var id = $("#id").val();
        if (null ==startTm || ''==startTm ){
            UIUtils.alertError("请选择开始时间");
            return;
        }
        if (null ==endTm || ''==endTm ){
            UIUtils.alertError("请选择结束时间");
            return;
        }
        if (endTm < startTm){
            var start = Date.parse("9999-12-31 "+startTm+":00");
            var end = Date.parse("9999-12-31 "+endTm+":00");
            if (start>end){
                UIUtils.alertError("开始时间不能大于结束时间");
                return;
            }
        }
        $.ajax({
            url:"<%=path%>/institution/nosigndate/updatenosigndate.do",
            data:JSON.stringify({
                id:id,
                insId:insId,
                startTime:"9999-12-31 "+startTm+":00",
                endTime:"9999-12-31 "+endTm+":00",
                insertFlag:false
            }),
            dataType:"json",
            type:"post",
            contentType:"application/json; charset=utf-8",
            async:false,
            cache:false,
            success: function (msg) {
                debugger;
                if (msg.success == 1) {
                    top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    parent.$("#searchBtn").click();
                    frameElement.dialog.close();
                }else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            },
            error:function () {
                UIUtils.alertError("保存失败");
            }
        });

    });
</script>

</body>
</html>